package io.renren.dao;

import io.renren.common.dao.BaseDao;
import io.renren.dto.TemporaryOrdermxDTO;
import io.renren.entity.TemporaryOrdermxEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 临时采购明细表 
 *
 * @author 翟文闯 619556390@QQ.com
 * @since 1.0.0 2019-12-31
 */
@Mapper
public interface TemporaryOrdermxDao extends BaseDao<TemporaryOrdermxEntity> {
    @Select("select A.*,( SELECT b.supplier_name FROM canteens_supplier B WHERE A.supplier_id = B.supplier_id ) AS supplier_name " +
            " from canteens_temporary_ordermx A where A.temporary_id = '${temporaryId}'  GROUP BY A.supplier_id")
    List<TemporaryOrdermxDTO> getTemsupplier(Long temporaryId );
    @Select("SELECT A.*,( SELECT b.supplier_name FROM canteens_supplier B WHERE A.supplier_id = B.supplier_id ) AS supplier_name, " +
            "(SELECT  c.type  from  canteens_food C where c.food_id = A.food_id)  type, " +
            " (SELECT  c.food_name  from  canteens_food C where c.food_id = A.food_id)  food_name " +
            "from canteens_temporary_ordermx A  where A.temporary_id = '${temporaryId}' and A.supplier_id = '${supplierId}'")
    List<TemporaryOrdermxDTO> getTemOrderMx(Long temporaryId ,Long supplierId);
    @Select("SELECT A.*," +
            "(SELECT  c.type  from  canteens_food C where c.food_id = A.food_id)  type, " +
            " (SELECT  c.food_name  from  canteens_food C where c.food_id = A.food_id)  food_name " +
            "from canteens_temporary_ordermx A  where A.temporary_id = '${temporaryId}' ")
    List<TemporaryOrdermxDTO> getTemOrderCollMx(Long temporaryId );

    @Select("DELETE from  canteens_temporary_ordermx   where temporary_id = '${temporaryId}'")
    void deleteOrder(Long temporaryId);
    @Select("select * from canteens_temporary_ordermx where temporary_id = '${temporaryId}' and   food_id = '${foodId}' ")
    TemporaryOrdermxDTO getTemOrd(Long temporaryId ,Long foodId);
}